package cm.day14.Test1;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class StudnetTest {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        //获取Class对象
        Class<Student> clz = Student.class;
        //获取全参构造方法
        Constructor<Student> cos = clz.getConstructor(String.class, int.class);
        System.out.println(cos);
        //调用方法传入参数
        Student str = cos.newInstance("柳岩", 17);
        //
        Method method = clz.getDeclaredMethod("show");
        //
        method.setAccessible(true);
        String result = (String) method.invoke(str);
        System.out.println(result);

    }
}
